package de.jenseins.utils.propertytranslator.gui;

import java.io.File;

import javax.swing.JFileChooser;

/**
 * 
 * 
 * @author Jens Greive
 * @since 01.12.2009
 * 
 */
public class FilePicker {

	public static File getSourceFile() {
		final JFileChooser fc = new JFileChooser();
		fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
		fc.setMultiSelectionEnabled(false);
		fc.setDialogType(JFileChooser.OPEN_DIALOG);
		int returnVal = fc.showOpenDialog(null);
		if (returnVal == JFileChooser.APPROVE_OPTION) {
			File file = fc.getSelectedFile();
			return file;
		}
		return null;
	}

	public static File getTargetDir(File suggestedFile) {
		final JFileChooser fc = new JFileChooser(suggestedFile.getParentFile());
		fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		fc.setSelectedFile(suggestedFile);
		fc.setMultiSelectionEnabled(false);
		fc.setDialogType(JFileChooser.SAVE_DIALOG);
		int returnVal = fc.showSaveDialog(null);
		if (returnVal == JFileChooser.APPROVE_OPTION) {
			File file = fc.getSelectedFile();
			return file;
		}
		return null;
	}

}
